//
//  BaseTableViewController.swift
//  SinaWeibo
//
//  Created by Apple on 15/11/8.
//  Copyright © 2015年 Apple. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {
    
    var userLogin = UserAccountViewModel().userLogin

    var  visitorLoginView: VisitorLoginView?
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    override func loadView() {
        userLogin ? super.loadView() : loadVisitorView()
    }
    private func loadVisitorView(){
        visitorLoginView = VisitorLoginView()
        visitorLoginView?.visitorDelegate = self
        view = visitorLoginView
        
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorWillRegister")
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登陆", style: .Plain, target: self, action: "visitorWillLogin")
    }
    //MARK协议方法
    ////请求
    //https://api.weibo.com/oauth2/authorize?client_id=123050457758183&redirect_uri=http://www.example.com/response&response_type=code
    func visitorWillRegister() {
        print("come on")
    }
    func visitorWillLogin() {
        print("come in")
        let oauth = OAuthViewController()
        let nav = UINavigationController(rootViewController: oauth)
        presentViewController(nav, animated: true, completion: nil)

    }
}
